<?php

$messages = $this->messages;
if (count($messages)) {
    $html = '';
    foreach ($messages as $msg) {
        switch ($msg['result']) {
            case 'success':
                $html .= '<div class="alert alert-success">';
                $html .= '<a href="#" data-dismiss="alert" class="close">×</a>';
                $html .= '<h4 class="alert-heading">Success!</h4>';
                $html .= $msg['message'];
                $html .= '</div>' . PHP_EOL;
                break;
            case 'error':
            case 'failed':
                $html .= '<div class="alert alert-error">';
                $html .= '<a href="#" data-dismiss="alert" class="close">×</a>';
                $html .= '<h4 class="alert-heading">Error!</h4>';
                $html .= $msg['message'];
                $html .= '</div>' . PHP_EOL;
                break;
            case 'info':
                $html .= '<div class="alert alert-info">';
                $html .= '<a href="#" data-dismiss="alert" class="close">×</a>';
                $html .= '<h4 class="alert-heading">Information!</h4>';
                $html .= $msg['message'];
                $html .= '</div>' . PHP_EOL;
                break;
            case 'warning':
                $html .= '<div class="alert">';
                $html .= '<a href="#" data-dismiss="alert" class="close">×</a>';
                $html .= '<h4 class="alert-heading">Warning!</h4>';
                $html .= $msg['message'];
                $html .= '</div>' . PHP_EOL;
                break;
            default:
                break;
        }
    }
    echo $html;
}
?>